<div id="navigation">
    <ul>
        <li class="active"><a href="index.php">Home</a></li>
       
     
    </ul>
    <div style="clear: both"></div>
</div>
<?php
require_once './model/works.php';
$md_works = new Works();
$id_work = $_GET['id'];
$params = array (
    'id_works' => $id_work
);
$work = $md_works->select($params);
?>
<form  method="post"      enctype="multipart/form-data">
    <input type="text" name="name" value="<?php echo $work[0]['name']?>"><br>
    <input type="text" name="description" value="<?php echo $work[0]['description']?>"><br>
    <input type="file" name="file"><br>
    <input type="submit" name="submit" value="Save">
</form>

<?php
if (isset($_POST['submit'])){
    if(isset($_FILES['file']['name'])){
        move_uploaded_file($_FILES['file']['tmp_name'], 'public/images/'.$_FILES['file']['name']);
     
    }
    $value = array(
        'id' => $id_work,
        'name'=> $_POST['name'],
        'description'=> $_POST['description'],
        'image' => 'public/images/' .$_FILES['file']['name']
    );
    $md_works->update($value);
    echo 'thanh cong';
}
?>

